import { useNavigate,useParams,useSearchParams } from "react-router-dom";

function withRouter (WrappedComponent){
  return function(props){
    const navigate = useNavigate(); // 路由跳转
    const params = useParams(); //获取路由参数params参数
    const [ URLSearchParams ] = useSearchParams()
    const query = Object.fromEntries(URLSearchParams.entries()); // 获取路由参数query参数
    const router = {navigate,params,query};
    return <WrappedComponent {...props} router={router}></WrappedComponent>
  }
}

export default withRouter;